<?php 

if (!empty($_POST)) die;

$cond = "WHERE city = $forum_city";

$topic_news = dt_query("SELECT id, title FROM forum_topic $cond ORDER BY l_r_at DESC LIMIT 6");
if (!$topic_news) die('获取数据失败！');
$topic_hots = dt_query("SELECT id, title FROM forum_topic $cond ORDER BY today_up_c DESC LIMIT 6");
if (!$topic_hots) die('获取数据失败！');

$kinds = dt_query("SELECT id, name FROM forum_kind $cond ORDER BY today_up_c DESC");
if (!$kinds) die('获取kind数据失败！');

?>
<?php if (1 == $city_info['carousel']) { ?>
<?php $carousels = dt_query_array("SELECT img_url, img_link FROM forum_carousel $cond ORDER BY m_at DESC LIMIT 40") ?>
<div class="carousel slide forum-carousel" id="carousel-1">
	<ol class="carousel-indicators">
		<?php foreach ($carousels as $key => $c) { ?>
		<?php if (8 > $key) { ?>
		<li class="<?php if (0 == $key) echo 'active' ?>" data-slide-to="<?php echo $key ?>" data-target="#carousel-1"> </li>
		<?php } ?>
		<?php } ?>
	</ol>
	<div class="carousel-inner">
		<?php foreach ($carousels as $key => $c) { ?>
		<div class="item <?php if (0 == $key) echo 'active' ?>">
			<a target="_blank" href="<?php echo $c['img_link'] ?>"><div style="background-image:url('<?php echo $c['img_url'] ?>')"></div></a>
		</div>
		<?php } ?>
	</div> <a class="left carousel-control" href="#carousel-1" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a> <a class="right carousel-control" href="#carousel-1" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
<?php } ?>
<div class="container index-box-1">
	<a target="_blank" href="<?php echo $city_info['index_img_link'] ?>"><div class="col-md-4 column index-box-1-img hidden-xs hidden-sm" style="background-image:url('<?php echo $city_info['index_img_url'] ?>')"></div></a>
	<div class="col-md-4 column">
		<h3><a href="?c=forum&a=topic_my_list&m_falter=3"><img src="img/finance/hengxin_logo_sm_1.png" height="25px"> 新发布 <small>>></small></a> </h3>
		<ul class="list-unstyled">
			<?php while($topic_new = mysql_fetch_array($topic_news)) { ?>
			<li><div class="title-a" ><a target="_blank" href="<?php echo s_url('?c=forum&a=topic_show&topic_id='.$topic_new['id']) ?>"><?php echo $topic_new['title'] ?></a></div></li>
			<?php } ?>
		</ul>

	</div>
	<div class="col-md-4 column hidden-xs hidden-sm">
		<h3><a href="?c=forum&a=topic_my_list&m_falter=4"><img src="img/finance/hengxin_logo_sm_1.png" height="25px"> 最关注 <small>>></small></a> </h3>
		<ul class="list-unstyled">
			<?php while($topic_hot = mysql_fetch_array($topic_hots)) { ?>
			<li></small><div class="title-a" ><a target="_blank" href="<?php echo s_url('?c=forum&a=topic_show&topic_id='.$topic_hot['id']) ?>"><?php echo $topic_hot['title'] ?></a></div></li>
		<?php } ?>
	</ul>
</div>
</div>
<br><br><br>
<div class="container forum-list-search">
	<div class="row clearfix">
		<div class="col-md-4 col-xs-2 column">
		</div>
		<div class="col-md-4 col-xs-8 column">
			<form id="search" action="javascript:forum_list_search()">	
				<div class="input-group">
					<input id="forum_list_search" class="form-control" type="text" placeholder="搜索">
					<a href="javascript:onclick=$('form#search').submit()" class="input-group-addon btn"><span class="glyphicon glyphicon-search"></span></a>
				</div>
			</form>	
		</div>
	</div>
</div>
<?php while($kind = mysql_fetch_array($kinds)) { ?>
<?php $forums = dt_query("SELECT * FROM forum WHERE kind = '".$kind['id']."' ORDER BY today_up_c DESC LIMIT 12") ?>
<div class="container index-forum">
	<h3><a target="_blank" href="<?php echo s_url('?c=forum&a=forum_list&m_falter=5&kind='.$kind['id']) ?>"><img src="img/finance/hengxin_logo_sm_1.png" height="25px"> <?php echo $kind['name'] ?> <small>>></small></a></h3>
	<?php while($forum = mysql_fetch_array($forums)) { ?>
	<div class="col-md-2 col-sm-3 col-xs-4 column">
		<a target="_blank" href="<?php echo s_url('?c=forum&a=topic_list&forum_id='.$forum['id']) ?>">
			<div class="row forum-item">
				<div class="forum-info">
					<h4> <?php echo $forum['name'] ?> <?php if (date('Ymd', time()) == $forum['today']) echo '<b class="badge">'.$forum['today_reply_c'].'</b>' ?></h4>
					<p class="hidden-xs"><?php echo $forum['intro'] ?></p>
				</div>
			</div>
		</a>
	</div>
	<?php } ?>
</div>
<?php } ?>
<script type="text/javascript">
$(document).ready(function(){
	$('li#forum_index').addClass('active');
	auto_c_h(0.35);
	<?php if (!empty($_GET['app_version']) && (1.04 != $_GET['app_version'])) { ?>
	if (confirm ("恒信网有新APP了,快更新来看看吧！^_^")) location = '<?php echo APP_URL ?>';
	<?php } ?>
});

</script>
